package sourceagile.webservices;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.codehaus.jettison.json.JSONArray;

import sourceagile.server.classRepositories.subversionFileRepository.ListRepositoryFiles;

@Path("/filesList")
public class ListFiles {

	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public static JSONArray getListClasses() {

		String repositoryURL = "https:--tictactoe4j.googlecode.com-svn-trunk-src-tictactoe-client";

		String username = "Alline.Oliveira";

		String password = "bD8Km8se2rV9";

		return getListClasses(repositoryURL, username, password);

	}

	@GET
	@Path("{repositoryURL}/{username}/{password}")
	@Produces(MediaType.APPLICATION_JSON)
	public static JSONArray getListClasses(
			@PathParam("repositoryURL") String repositoryURL,
			@PathParam("username") String username,
			@PathParam("password") String password) {

		repositoryURL = repositoryURL.replaceAll("-", "/");

		return ListRepositoryFiles.listEntries(repositoryURL, username,
				password);

	}
}
